/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package semantics;

import java.util.LinkedList;
import java.util.Map;
import syntax.Clock;
import syntax.Transition;

/**
 *
 * @author hicham
 */
public class Run {
    private LinkedList<RunStep> path;
    private State lastState;
    private float bestDelay;

    public Run() {
        path = new LinkedList<RunStep>();
    }

    public LinkedList<RunStep> getPath() {
        return path;
    }

    public void setPath(LinkedList<RunStep> path) {
        this.path = path;
    }

    public State getLastState() {
        return lastState;
    }

    public void setLastState(State lastState) {
        this.lastState = lastState;
    }

    public float getBestDelay() {
        return bestDelay;
    }

    public void setBestDelay(float bestDelay) {
        this.bestDelay = bestDelay;
    }
    
    public void appendRun(Run run) {
        path.addAll(run.getPath());
    }

    public Transition getLastTrans() {
        if (getPath().isEmpty()) {
            return null;
        }
        else {
            return getPath().getLast().getTransition();
        }    
    }
    
    @Override
    public String toString() {
        StringBuilder stb = new StringBuilder();
        stb.append("\n*********************************************\n");
        stb.append("LAST STATE\n");
        stb.append(lastState);
        stb.append("\n=========================\n");
        stb.append("BEST DELAY\n");
        stb.append(bestDelay);
        stb.append("\n=========================\n");
        stb.append("PATH\n");        
        for (RunStep step : path){
            stb.append(step).append(",");            
        }
        stb.append("\n");        
        stb.append("*********************************************\n");
        return stb.toString();
    }
    
    
}
